home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Programming / SWI / source / porting < prev    next >
Encoding:
Text File  |  1995-04-26  |  3.6 KB  |  115 lines

  1.             Porting SWI-Prolog
  2.  
  3.  
  4. Below  are some  notes meant for  those who decide  to modify  or port
  5. SWI-Prolog.  It is by no means complete.
  6.  
  7. SAVE/1 AND FRIENDS
  8. ==================
  9.  
  10. If autoconf fails to detect  a  working   save/1,  read  the comments in
  11. pl-save.c and work on a stand-alone test version of this system using
  12.  
  13.     % gcc -DTEST pl-save.c
  14.  
  15. Two things generally need attention.  First is   to get the start of the
  16. data segment right.  Compile and link a very small program and run 
  17.  
  18.     % nm -n a.out
  19.  
  20. on the executable.  Find the start of the data-segment and decide on the
  21. proper definition:
  22.  
  23.     #define DATA_START
  24. or
  25.     #define FIRST_DATA_SYMBOL
  26.  
  27. The initialised data, uninitialised data and  malloc() heap are supposed
  28. to be between DATA_START and sbrk(0).  If   not  (like OS2), rewrite the
  29. code that defines the savable segments.   See   the  #ifdef  OS2's for a
  30. start.
  31.  
  32. Second problems is the type of linking used.  See INSTALL.notes.
  33.  
  34.  
  35. LOAD_FOREIGN AND FRIENDS
  36. ========================
  37.  
  38. If there is some supported version of foreign loading on your system and
  39. it is not detected, add it.
  40.  
  41. ld -A/a.out loading may be detected, but   may  fail to compile, link or
  42. work.  Add the proper definitions to pl-load.c.
  43.  
  44.     
  45. VIRTUAL MEMORY BASED DYNAMIC STACKS
  46. ===================================
  47.  
  48. Based on mmap()/munmap() of /dev/zero to   allocate  memory at arbitrary
  49. places  in  the  address   space.    This    doesn't   work   with  many
  50. implementations of mmap() due to  various   restrictions:  cannot map at
  51. arbitrary page boundary, can only map limited pages, cannot map private,
  52. etc.  Work on test/mmap() if the test   fails, but you think your mmap()
  53. is good enough.  If there are other   ways  to achieve this goal, please
  54. let me know.  
  55.  
  56.  
  57. MEMORY ERRORS (BUS ERROR; SEGMENTATION FAULT)
  58. =============================================
  59.  
  60. It is very likely that the system crashes during  the boot compilation
  61. called from  make (./pl   -O  -o  ...  -b ...  -c  ...).  Below  is  a
  62. description of various such problems:
  63.  
  64.  
  65. WORKING ON A SMALL PROGRAM
  66. ==========================
  67.  
  68. [skip this, it is out of date, and doesn't work anymore.  Debug using
  69.  
  70.  ./pl -d <n> -b ../boot/init.pl
  71.  
  72.  where <n> is the debugging level to be used.
  73. ]
  74.  
  75. If  you are   very lucky  the   system will  compile and perform   the
  76. bootstrap compilation in one go.  Normally you are not.  On how to get
  77. it through the C compiler, you  are on your  own.  If  the system does
  78. not want to do the bootstrap compilation, write a small prolog program
  79. that  can   be handled by the   bootstrap  compiler and work  on that.
  80. Normally, I use
  81.  
  82. :- write('Hello World!').
  83. :- nl.
  84.  
  85. You can  compile this using `pl -d   level -b file'.  If  this finally
  86. writes `Hello  World' on  your terminal you  are  getting close.  Next
  87. test program can be:
  88.  
  89. test :-
  90.     write('Hello World'),
  91.     nl.
  92.  
  93. $init :-
  94.     test,
  95.     halt.
  96.  
  97. If you can compile this and you  can run the  result by typing `a.out'
  98. or `pl   -x  a.out -d level' you   can  try to  do   the   entire boot
  99. compilation.  If you decide to write  more elaborate test programs you
  100. should realise  many things are not yet   defined.  Initially  you can
  101. only call  the foreign language   predicates, defined   in   pl-ext.c.
  102. Constructs handles by the compiler  (,/2, !, ->/2,  ;/2, etc.)  cannot
  103. be called   via metacall or   directives (but can be used   in program
  104. text).
  105.  
  106.  
  107. CODE USED ATOMS OR FUNCTORS
  108. ===========================
  109.  
  110. Atoms needed by the C  sources are addressed using  macros of the form
  111. ATOM_<name>.  Functors have  the form FUNCTOR_<name><arity>.   See the
  112. file ATOMS.  The awk script defatoms is invoked by make  to create the
  113. necessary C source and header files.  These files are named *.i[ch].
  114.  
  115.